import { ChannelActionType, ChannelItem } from '..'

const initValue: {
  channels: ChannelItem[],
  index: number
} = {
  channels: [],
  index: 0
}
export default function channel (state = initValue, action: ChannelActionType) {
  console.log('channel', action)
  if (action.type === 'channel/SET_CHANNELS') {
    return { ...state, channels: action.initState }
  } else if (action.type === 'channel/SET_CHANNEL_INDEX') {
    return { ...state, index: action.payload }
  }
  return state
}
